home *** CD-ROM | disk | FTP | other *** search
- //: C09:Macro.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Side effects with macros
- #include "../require.h"
- #include <fstream>
- using namespace std;
-
- #define BAND(X) (((X)>5 && (X)<10) ? (X) : 0)
-
- int main() {
- ofstream out("macro.out");
- assure(out, "macro.out");
- for(int i = 4; i < 11; i++) {
- int a = i;
- out << "a = " << a << endl << '\t';
- out << "BAND(++a)=" << BAND(++a) << endl;
- out << "\t a = " << a << endl;
- }
- } ///:~
-